package com.TanNgee.ThreadPoolExercise;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

/**
 * @author 陈毅
 * @create 2022/4/26 0:19
 *
 * https://www.bilibili.com/video/BV18J41157DX?p=27
 */
public class MyTest {
    public static void main(String[] args) {
        final ExecutorService executorService = Executors.newFixedThreadPool(10, new ThreadFactory() {
            int id = 1;

            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r, "ATM" + id++);
            }
        });
        for (int i = 0; i < 5; i++) {
            final MyTask myTask = new MyTask("线程" + i);
            executorService.submit(myTask);
        }
    }
}
